<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 300px;        
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
        const oBox = document.querySelector('.box')

        function enterHandle (){
            console.log(111);
            this.style.backgroundColor = 'yellowgreen'
        }

        function leaveHandle(){
            console.log(222);
            this.style.backgroundColor = ''
        }

        //  _.throttle(节流核心函数，时间，{leading:默认为true,})

        oBox.onmouseenter = _.throttle(enterHandle,3000,{leading:true,trailing:false})
        oBox.onmouseleave = _.throttle(leaveHandle,3000,{leading:true,trailing:true} )


    </script>
</body>
</html>